package com.oocl.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.oocl.dao.FavoriteDao;
import com.oocl.dao.impl.FavoriteDaoImpl;
import com.oocl.formV1.util.FavoriteDB;
import com.oocl.pojo.Favorite;
import com.oocl.service.FavoriteService;
import com.oocl.service.impl.FavoriteServiceImpl;

/**
 * Servlet implementation class InitServlet
 */
public class InitServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    private FavoriteService service; 
	
    /**
     * @see HttpServlet#HttpServlet()
     */
    public InitServlet() {
    	service = new FavoriteServiceImpl();
    }

	@Override
	public void init() throws ServletException {
		FavoriteDB.setFavorites(service.findAll());
		
		for(String f:FavoriteDB.getFavorites().keySet()){
			System.out.println(f);
		}
		
		this.getServletContext().setAttribute("favs", FavoriteDB.getFavorites());
	}

}
